South Sudan Imports

The Treemap

Photo from Wikimedia Commons

Photo from Wikimedia Commons

Nature makes penicillin; I just found it…
— Alexander Fleming

According to the Observatory of Economic Complexity (OEC), in 2019 South Sudan imported $667M, making it the number 186 trade destination in the world. The most recent imports of South Sudan are led by Cars, Delivery Trucks, Packaged Medicaments, Other Edible Preparations, and Knit Men’s Coats. The most common import partners for South Sudan are United Arab Emirates, Kenya, China, Switzerland, and Netherlands.

Let’s use the treemap layout to take a closer look.


Ingest the data

imports, section, hs levels, and trade value

# Load data
df = read.csv("archetypes/south-sudan-imports/imports-2019/imports-hs6-2019.csv", header = TRUE, stringsAsFactors = TRUE)  # 
df

origins, all

df_origins = read.csv("archetypes/south-sudan-imports/origins-2019/origins-2019.csv", header = TRUE, stringsAsFactors = TRUE)  # 
df_origins

origins, packaged-medicaments

df_origins_pm = read.csv("archetypes/south-sudan-imports/origins-2019/origins-of-packaged-medicaments-2019.csv", header = TRUE, stringsAsFactors = TRUE)  # 
df_origins_pm

Wrangle the data

select only the needed, filter

df_wrangle <- df %>% select(Section, HS2, HS4, HS6, Trade.Value)
# df_wrangle

df_wrangle_pm <- filter(df_wrangle, HS4 == 'Packaged Medicaments')
df_wrangle_pm
df_origins_wrangle <- df_origins %>% select(Continent, Country, Trade.Value)
# df_origins_wrangle

df_origins_pm_wrangle <- df_origins_pm %>% select(Continent, Country, Trade.Value)
# df_origins_pm_wrangle

Plot the Treemap, Imports

area, fill, labels, and subgroups

section_palette <- c(
   'Animal Products' = '#a0d447',
   'Vegetable Products' = '#ed40f2',
   'Animal and Vegetable Bi-Products Foodstuffs' = '#02a347',
   'Mineral Products' = '#aa7329',
   'Chemical Products' = '#f4ce0f',
   'Plastics and Rubbers' = "#ed40f2",
   'Animal Hides' = '#ff73ff',
   'Wood Products' = '#efdc81',
   'Paper Goods' = '#9c9fb2',
   'Textiles' = '#a53200',
   'Footwear and Headwear' = '#2cba0f',
   'Stone And Glass' = '#9e0071',
   'Precious Metals' = '#f46d2a',
   'Metals' = '#edb73e',
   'Machines' = "#2e97ff",
   'Transportation' = "#69c8ed",
   'Instruments' = '#f2aa86',
   'Weapons' = '#dd0e31',
   'Miscellaneous' = '#6df2b0',
   'Arts and Antiques' = '#9cf2cf'
)

# Layouts
# squarified" (the default), "scol", "srow" or "fixed"

v1 <- ggplot(df_wrangle, aes(area = Trade.Value, fill = Section, label = HS6, subgroup = Section)) +
  geom_treemap() +
  geom_treemap_subgroup_border(colour = "white") +
  geom_treemap_subgroup_text(place = "centre", grow = T, alpha = 0.5, colour =
                               "black", fontface = "italic", min.size = 0) +
  geom_treemap_text(colour = "white", place = "topleft", reflow = T) +
  scale_fill_manual(values = section_palette) +
  theme_minimal() +
  theme(legend.position = "none")

girafe(ggobj = v1, width_svg = 1280/72, height_svg = 720/72,
       options = list(opts_sizing(rescale = TRUE, width = 1.0))
)

Plot the Treemap, Origins

area, fill, labels, and subgroups

continent_palette <- c(
   'Africa' = '#a0d447',
   'Asia' = '#a53200',
   'Europe' = '#2e97ff',
   'North America' = '#69c8ed',
   'Oceania' = '#f4ce0f',
   'South America' = "#edb73e"
)

# Layouts
# squarified" (the default), "scol", "srow" or "fixed"

v2 <- ggplot(df_origins_wrangle, aes(area = Trade.Value, fill = Continent, label = Country, subgroup = Continent)) +
  geom_treemap() +
  geom_treemap_subgroup_border(colour = "white") +
  geom_treemap_subgroup_text(place = "centre", grow = T, alpha = 0.5, colour =
                               "black", fontface = "italic", min.size = 0) +
  geom_treemap_text(colour = "white", place = "topleft", reflow = T) +
  scale_fill_manual(values = continent_palette) +
  theme_minimal() +
  theme(legend.position = "none")

girafe(ggobj = v2, width_svg = 1280/72, height_svg = 720/72,
       options = list(opts_sizing(rescale = TRUE, width = 1.0))
)

Imports and Origins, Packaged Medicaments

side-by-side layout

v3 <- ggplot(df_wrangle_pm, aes(area = Trade.Value, fill = Section, label = HS6, subgroup = Section)) +
  geom_treemap() +
  geom_treemap_subgroup_border(colour = "white") +
  geom_treemap_subgroup_text(place = "centre", grow = T, alpha = 0.5, colour =
                               "black", fontface = "italic", min.size = 0) +
  geom_treemap_text(colour = "white", place = "topleft", reflow = T) +
  scale_fill_manual(values = section_palette) +
  theme_minimal() +
  theme(legend.position = "none")

v4 <- ggplot(df_origins_pm_wrangle, aes(area = Trade.Value, fill = Continent, label = Country, subgroup = Continent)) +
  geom_treemap() +
  geom_treemap_subgroup_border(colour = "white") +
  geom_treemap_subgroup_text(place = "centre", grow = T, alpha = 0.5, colour =
                               "black", fontface = "italic", min.size = 0) +
  geom_treemap_text(colour = "white", place = "topleft", reflow = T) +
  scale_fill_manual(values = continent_palette) +
  theme_minimal() +
  theme(legend.position = "none")

girafe( ggobj = plot_grid(v3, v4), width_svg = 1280/72, height_svg = 720/72,
       options = list(opts_sizing(rescale = TRUE, width = 1.0))
)

References

citations for narrative and data sources

## [1] Datawheel. _South Sudan (SSD) Exports, Imports, and Trade
## Partners_. oec.world, 2013. <URL:
## https://oec.world/en/profile/country/ssd> (visited on 06/18/2021).